Fix Gemini Model Integration Issues (#2803) #2804
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix Gemini Model Integration Issues
Fixes #2803
Description
This PR addresses the issue where Google Gemini models fail in CrewAI due to LiteLLM API key and model parsing issues. The fix handles two main problems:
API Key Mapping: LiteLLM expects
GEMINI_API_KEY
but users typically setGOOGLE_API_KEY
. This PR adds automatic mapping fromGOOGLE_API_KEY
toGEMINI_API_KEY
when using Gemini models.Model Name Normalization: Model formats like "models/gemini-pro" or "gemini-pro" aren't parsed correctly as provider/model. This PR adds normalization to ensure all Gemini model names are in the correct format for LiteLLM (gemini/model-name).
Changes
_is_gemini_model
method to detect Gemini models_normalize_gemini_model
method to handle different model formatsGOOGLE_API_KEY
toGEMINI_API_KEY
How to Test
Link to Devin run
https://app.devin.ai/sessions/f9b3766170dd4ab1863f9b34c9f38f96
Requested by: Joe Moura ([email protected])